package com.org.utils;

import com.org.pojo.Serve;
import com.org.pojo.Skill;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.List;

public class MatchUtil {

    // 时间35分，距离30分，类型35分
    public static double getScore(
            Skill skill,
            Serve serve
    ){
        // 技能信息
        List<String> skillTypes = Arrays.asList(skill.getLable01(), skill.getLable02(), skill.getLable03(), skill.getLable04());
        LocalDateTime skillStartTime = skill.getStarttime();
        LocalDateTime skillEndTime = skill.getEndtime();

        // 服务信息
        String serveTypes = serve.getType();
        LocalDateTime serveStartTime = serve.getStartTime();
        LocalDateTime serveEndTime = serve.getEndTime();

        // 匹配度得分
        double score = 0;
        // 类型匹配
        if(skillTypes.contains(serveTypes)){
            score += 30;
        }
        // 时间匹配等级1
        if(skillStartTime.isBefore(serveStartTime) && skillEndTime.isAfter(serveEndTime)){
            score += 40;
        }
        if(skillStartTime.equals(serveStartTime) && skillEndTime.equals(serveEndTime)){
            score += 40;
        }
        if(skillStartTime.equals(serveStartTime) && skillEndTime.isAfter(serveEndTime)){
            score += 40;
        }
        if(skillStartTime.isBefore(serveStartTime) && skillEndTime.equals(serveEndTime)){
            score += 40;
        }
        // 时间匹配等级2
        if(skillStartTime.isBefore(serveStartTime) && skillEndTime.isBefore(serveEndTime)){
            score += 25;
        }
        // 时间匹配等级2
        if(skillStartTime.isAfter(serveStartTime) && skillEndTime.isAfter(serveEndTime)){
            score += 25;
        }
        // 时间匹配等级3
        if(skillStartTime.isAfter(serveStartTime) && skillEndTime.isBefore(serveEndTime)){
            score += 10;
        }
        // 时间不匹配不加分

        return score;

    }

}
